<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>1.何为数据代理</title>
  </head>
  <body>
    <script type="text/javascript" >
      // 想通过obj1操作obj2中的a属性
      let obj1 = {x:100,y:200}
      let obj2 = {a:1,b:2}

      Object.defineProperty(obj1,'a',{
        get(){
          return obj2.a
        },
        set(value){
          obj2.a = value
        }
      })

      console.log(obj1)
    </script>
  </body>
</html>